<?php

/**
 * [PHPFOX_HEADER]
 */
defined('PHPFOX') or exit('No direct script access allowed.');

/**
 *
 *
 */
class Profiles_Component_Block_View extends Phpfox_Component {

	/**
	 * Class process method wnich is used to execute this component.
	 */
	public function process()
	{
        $usernames = Phpfox::getService('profiles.process')->getUserNames($name);
        $profiles_selected_user = Phpfox::getLib('session')->get('profiles_selected_user');
        $oSession = Phpfox::getLib('session');
        if($error = $oSession->get('pro_error')){
            $aVals = $oSession->get('pro_vals');
            $oSession->remove('pro_error');
            $oSession->remove('pro_vals');
        }else{
            $success = $oSession->get('pro_vals');
            $oSession->remove('pro_error');
            $oSession->remove('pro_vals');
            Phpfox::getLib('session')->remove('profiles_selected_user');
        }

        if($profiles_selected_user){
            if($profiles_selected_user['user_id']){
                $user = Phpfox::getService('profiles.process')->getUserById($profiles_selected_user['user_id']);
                if($user['not_friend']){
                    $aVals['type'] = 1;
                }else{
                    $aVals['type'] = 0;
                }
            }else{
                $user['user_id'] = '-1';
                $user['full_name'] = $profiles_selected_user['username'];
                $user['not_friend'] = 1;
                $aVals['type'] = 2;
            }
        }else{
            $user = array();
        }
        $this->template()
            ->assign(array(
                'error' => $error,
                'success' => $success,
                'user' => $user,
                'aVals' => $aVals
            )
        );
	}

	/**
	 * Garbage collector. Is executed after this class has completed
	 * its job and the template has also been displayed.
	 */
	public function clean()
	{
		
	}

}

?>